<h1>DefineButton2</h1>

<p>DefineButton2 defines the appearance and actions of push and menu buttons. It 
provides a more sophisticated model for creating buttons than the DefineButton
instruction:</p>

<div style="padding-left:20px; margin-bottom:10px;">
<ul>
<li>Two types of button are supported, <B>Push</B> and <B>Menu</B>.</li>
<li>The number of events that a button can respond to is increased.</li>
<li>Actions can be executed for any button event.</li>
</ul>
</div>

<p>Push and Menu buttons behave slightly differently in tracking mouse movements 
when the button is clicked. A Push button 'captures' the mouse so if the cursor 
is dragged outside of the active area of the button and the mouse click is released 
then the Release Outside event is still sent to the button. A Menu button does 
not 'capture' the mouse so if the cursor is dragged out of the active area the 
button returns to its 'inactive' state.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">10</td>
<td>Identifies the DefineButton2 instruction when it is encoded. It is encoded 
with the length field as a 16-bit integer (Little-endian byte order).</td>
</tr>

<tr>
<td nowrap valign="top">length</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">6</td>
<td>The length in bytes of the body of the instruction when it is encoded. If the length is greater 
than 62 then this field is set to 0x3F and the length is encoded using the 
extendedLength field. Encoded with the type field as a 16-bit integer.</td>
</tr>

<tr>
<td nowrap valign="top">extendedLength</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>Optional. Contains the length in bytes of the encoded instruction if it is
greater than 62 bytes. If the length is 62 bytes or less then this field is 
omitted.</td>
</tr>

<tr>
<td nowrap valign="top">identifier</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The unique identifier for this button definition. This is used when adding or removing 
the shape from the display list or when the shape is used as part of another 
object such as a button.</td>
</tr>

<tr>
<td nowrap valign="top">buttonType</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>Whether the button is a Push button or a Menu button.</td>
</tr>

<tr>
<td nowrap valign="top">buttonRecords</td>
<td nowrap valign="top">Button[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of Buttons that describe the appearance of the button in 
each of its states.</td>
</tr>

<tr>
<td nowrap valign="top">buttonEvents</td>
<td nowrap valign="top">ButtonEvent[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of ButtonEvents that define the actions that are executed 
for each type of button event.</td>
</tr>

</table>

<p>DefineButton2 must contain at least one Button. If more 
than one button record is defined for a given button state then each shape will 
be displayed by the button. The order in which the shapes are displayed is 
determined by the layer assigned to each button record.</p>

<p>Each Button can contain a ColorTransform which can be used 
to change the colour of the shape being displayed without changing the original 
definition.</p>

<p>Actions do not need to be specified for every button event. Indeed actions do 
not need to be specified at all.</p>

<h2>History</h2>

<p>DefineButton2 represents the DefineButton2 structure from the 
Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.</p>
